home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Aminet / comm / www / IBrowseScripts.lha / ibrowsescripts / rexx / graburl.ibrx < prev    next >
Text File  |  1998-04-18  |  3KB  |  148 lines

  1. /*  $VER: graburl.ibrx 1.0     
  2.     Made by Sören Forsberg : sorenf@hem1.passagen.se
  3.   
  4. */
  5. /*
  6. fixa case oberoende i filtyps-sparning
  7. koll om någon anger "http://" som url,eller ingen url alls
  8. */
  9.  
  10. OPTIONS RESULTS
  11. OPTIONS FAILAT 15
  12. call addlib('rexxreqtools.library',0,-30)
  13.  
  14.  NL            ='0a'x        /* newline */
  15.  zero        ='00'x        /* zero */
  16.  
  17.  list            ='<PRE>'||NL||'<B>The following files were saved:</B>'||NL||NL
  18.  tot             =20000
  19.  last            =0 
  20.  fonttag         = "rt_font=" || 'topaz' || "/" || 8
  21.  cachepath    ='IBrowse:cache'    
  22.  title        ='Dumpfiles by sorenf@hem1.passagen.se 1998'
  23.  tags        ='rt_pubscrname=IBROWSESCREEN'  /* Change here the name of the screen IBROWSE runs */
  24.  noconfig_txt    ='I cannot find the config-file'||NL||'Please run Dumpfiles once First!'||NL||'I need you to locate your chache-drawer'
  25.  
  26. /* Read configuration, get new cachepath if missing or wrong */
  27.  
  28.  ok=open(configfile,'ibrowse:rexx/dumpfiles.config','R')
  29. IF ok THEN DO
  30.     cachepath=readln(configfile)
  31.     close(configfile)
  32. END
  33. IF ~exists(cachepath'globalcache') THEN ok=0
  34. IF ~ok THEN DO
  35.     sel=rtezrequest(noconfig_txt,,title, tags)
  36.     exit
  37. END
  38.  
  39.  
  40. address 'IBROWSE'
  41. 'QUERY URL'
  42. url = result
  43. url=url||zero
  44. IF LENGTH(url)<13 THEN DO
  45. sel=rtezrequest('Please use a valid cache-url',,title, tags)
  46. EXIT 
  47. END
  48. say url
  49. IF urllen<8 THEN EXIT
  50.  
  51. sel=2
  52.  
  53. /* Check with globalcache and save appropiate file */
  54. local=pos('file:',url)
  55. if local~=0 then do
  56.     len=LENGTH(url)
  57.     source=SUBSTR(url,18,len-17)
  58. END
  59. say source
  60. IF local=0 THEN DO
  61. ok=open(infile,cachepath'globalcache','R')
  62. if ~ok then exit
  63. input=readch(infile,tot)
  64.     
  65. Do FOREVER
  66. IF last=0 THEN last=1    
  67.     hit=POS(url,input,last)                    /* Find a url in cachelist */
  68.  
  69.     If hit>0 then Do
  70.         last=POS(zero,input,hit)
  71.         mid=last
  72.         last=POS(zero,input,last+1)
  73.         len=last-hit
  74.         yeah=SUBSTR(input,hit,len)
  75.         check=compare(url,yeah)                /* Check if we want it */
  76.         yeahupp=UPPER(yeah)
  77.         yeah=RIGHT(yeah,13)
  78.         test=pos(zero,yeah)
  79.         IF test~=0 THEN yeah=RIGHT(yeah,(LENGTH(yeah)-test))
  80.         source=cachepath||yeah
  81.         leave            
  82.     END
  83.     IF hit>(tot-200) | (hit=0) THEN DO                    /* Take a new bit of cachelist */
  84.         old=RIGHT(input,200)                        /* if needed                */
  85.         new=READCH(infile,tot-200)
  86.         input=old||new
  87.         last=last-(tot-200)
  88.         IF last<1 THEN last=1
  89.     END
  90.  
  91.     IF EOF(infile) | (hit~=0) THEN LEAVE                /* Are we done yet?            */
  92.  
  93. END
  94. ADDRESS 'AREXX' 
  95.    close(infile)
  96. END
  97.  
  98.  
  99.  
  100. list='<BIG>Non-linked possible URL''s<BIG><PRE>'||NL
  101.  
  102. ok=open(configfile,source,'R')
  103. say ok
  104. say source
  105.  
  106. dup_chars='.,!?"*%&)'    /* ta bort före och efter */
  107. IF ok THEN DO
  108. DO UNTIL EOF(configfile)
  109.     line=readln(configfile)
  110.     DO i=1 TO WORDS(line)
  111.         check=WORD(line,i)
  112.         check=STRIP(check,'B','.')
  113.         dot=pos('.',check)
  114.         IF dot~=0 THEN DO
  115.             dot1=pos('.',check,dot+1)
  116.             IF (dot1~=0) & ((dot+1)~=dot1) & (pos('=',check)=0) THEN DO
  117.                 check=STRIP(check,'B','"')
  118.                 list=list||'<A HREF="'||check||'">'||check||'</A>'||NL
  119.             END
  120.         END
  121.     END
  122. END
  123.  
  124.     close(configfile)
  125.  
  126. say list
  127. /*Save the list of files and send to IBrowse*/ 
  128. list=list||'</PRE>'
  129. ok=open(resultfile,'RAM:T/graburl.html','W')
  130. new=writeln(resultfile,list)
  131.  close(resultfile)
  132. address 'IBROWSE' 'GOTOURL file://localhost/RAM:T/graburl.html'
  133.  
  134. END
  135. Exit
  136.  
  137. /*
  138.  
  139. mailto om inneh @
  140. strippa alla dup tecken tills ok,  ska göras före punktcheck
  141. slopa kopiering till ram: läs direkt.
  142. koll om html
  143. göra en loop till check för att få antal punkter
  144. om html kolla att det inte finns en '<A HREF=' före '</A>' ,
  145. kräver att vi har en UPPER(line) att testa mot?
  146. läsa in och lägga ihop flera rader för att kunna kolla ovanstående
  147.  
  148. */